//
//  STOrderPushDetailController.swift
//  StarTimesON
//
//  Created by Toj on 10/19/23.
//  Copyright © 2023 StarTimes. All rights reserved.
//

import UIKit

// MARK: - 懒加载(属性), 变量, 初始化init
class STOrderPushDetailController: STBaseViewController {
    
    @objc var index: String? { didSet {
        let sIndex = index ?? ""
        indexNumber = Int(sIndex) ?? 0
    } }
    private var indexNumber = 0
    
    deinit {
        print("-->startimes: \(st_className) func: deinit")
    }
    
    private let viewModel = TVOrderViewModel()
    
    private lazy var pageView: STPageViewController = {
        let view = STPageViewController()
        
        var viewStyle = view.viewStyle
        viewStyle.backgroundColor = .navigation
        
        var cellStyle = view.viewStyle.titleStyle.cellStyle
        cellStyle.fillType = .const
        cellStyle.width = CGFloat.dv_width * 0.5
        cellStyle.textFont = UIFont.boldSystemFont(ofSize: 14)
        cellStyle.textColor = "#999999".to_color
        cellStyle.textSelectedColor = .white
        cellStyle.textBackgroundColor = .clear
        
        var lineStyle = view.viewStyle.titleStyle.lineStyle
        lineStyle.color = .white
        lineStyle.fillType = .fill
        
        return view
    }()
}

// MARK: - 生命周期
extension STOrderPushDetailController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        setupMakeInitialize()
        setupMakeAddSubviews()
        setupMakeLayoutSubviews()
        
        print("-->startimes: vc indexNumber: \(indexNumber)")
    }
}

// MARK: - 点击事件/ 通知事件回调
@objc private extension STOrderPushDetailController {
    
}

// MARK: - Public
extension STOrderPushDetailController {
    
}

// MARK: - Private
private extension STOrderPushDetailController {
    
}

// MARK: - 初始化设置
private extension STOrderPushDetailController {
    
    func setupMakeAddSubviews() {
        addChild(pageView)
        view.addSubview(pageView.view)
    }
    
    func setupMakeLayoutSubviews() {
        pageView.view.snp.makeConstraints { make in
            make.top.equalTo(navigationBar.snp.bottom).offset(0.2)
            make.left.right.bottom.equalTo(view)
        }
    }
    
    func setupMakeInitialize() {
        title = "Push/pre-Order VOD"
        view.backgroundColor = .gray
        
        var vcs = [UIViewController]()
        
        let free = STOrderPushController()
        free.pushType = .free
        free.pushTitle = "FREE PUSH CONTENT"
        vcs.append(free)
        
        let order = STOrderPushController()
        order.pushType = .order
        order.pushTitle = "RESERVATION CONTENT"
        vcs.append(order)
        
        let titles = [free.pushTitle, order.pushTitle]
        
        pageView.titles = titles
        pageView.views = vcs
    }
}
